package com.betterjr.modules.risk.loan.entity;

import java.io.Serializable;
import java.util.List;

public class HttpConnectionResult implements Serializable {

    /** 
     * @Fields serialVersionUID : 
     */
    private static final long serialVersionUID = -3850902248619017731L;

    private String code;

    private String message;

    private String errorMessage;

    private List<TransactionDTO> transactionLists;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public List<TransactionDTO> getTransactionLists() {
        return transactionLists;
    }

    public void setTransactionLists(List<TransactionDTO> transactionLists) {
        this.transactionLists = transactionLists;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((code == null) ? 0 : code.hashCode());
        result = prime * result + ((errorMessage == null) ? 0 : errorMessage.hashCode());
        result = prime * result + ((message == null) ? 0 : message.hashCode());
        result = prime * result + ((transactionLists == null) ? 0 : transactionLists.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (!(obj instanceof HttpConnectionResult)) {
            return false;
        }
        HttpConnectionResult other = (HttpConnectionResult) obj;
        if (code == null) {
            if (other.code != null) {
                return false;
            }
        } else if (!code.equals(other.code)) {
            return false;
        }
        if (errorMessage == null) {
            if (other.errorMessage != null) {
                return false;
            }
        } else if (!errorMessage.equals(other.errorMessage)) {
            return false;
        }
        if (message == null) {
            if (other.message != null) {
                return false;
            }
        } else if (!message.equals(other.message)) {
            return false;
        }
        if (transactionLists == null) {
            if (other.transactionLists != null) {
                return false;
            }
        } else if (!transactionLists.equals(other.transactionLists)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "HttpConnectionResult [code=" + code + ", message=" + message + ", errorMessage=" + errorMessage
                + ", transactionLists=" + transactionLists + "]";
    }

    public static HttpConnectionResult ok() {

        HttpConnectionResult result = new HttpConnectionResult();

        result.setCode("200");
        result.setErrorMessage("");
        result.setMessage("success");

        return result;

    }

    public static HttpConnectionResult fail() {

        HttpConnectionResult result = new HttpConnectionResult();

        result.setCode("300");
        result.setErrorMessage("error..");
        result.setMessage("fail");

        return result;

    }

}
